﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour {

    [Header("Scores")]
    public int player1Score;                            //Player 1's score.
    public int player2Score;                            //Player 2's score.

    [Header("Spawn Points")]
    public List<GameObject> spawnPoints = new List<GameObject>();	//A list of all the spawn points, which the players can spawn at.
    
    [Header("Prefabs")]
    public GameObject wallPrefab;

    [Header("Components")]
    public UI ui;                                       //The UI.cs script, located in the GameManager game object.

    private string mapToLoad;                           //The name of the map that is going to be loaded.
    private int maxScore=5;

    void Update()
    {
        //Checking Scores
        if (player1Score >= maxScore)
        {   //Does player 1 reach the score amount to win the game?
            WinGame(0);                 //Player 1 wins the game.
        }
        if (player2Score >= maxScore)
        {   //Does player 2 reach the score amount to win the game?
            WinGame(1);                 //Player 2 wins the game.
        }
    }

    private void WinGame(int v)
    {
        ui.SetWinScreen(v);	//Call the SetWinScreen function in UI.cs, and send over the winning player's id.
    }
}
